package structural_pattern.adapter_pattern;

/**
 * 适配者 二分查找
 */
public class BinarySearch {
    public  int binarySearch(int array[],int key){
        int low = 0;
        int hight = array.length -1 ;
        while (low<hight){
            int mid = (low+hight)/2;
            int midVal = array[mid];
            if (midVal<key){
                low = mid+1;
            }else  if (midVal>key){
                hight = mid-1;
            }else {
                return 1;
            }
        }
        return -1;
    }
}
